//
//  LEGoodStatusCell.m
//  LoveExpressBusiness
//
//  Created by 刘甲奇 on 2017/5/15.
//  Copyright © 2017年 DFH. All rights reserved.
//

#import "LEGoodStatusCell.h"
#import "UIImageView+WebCache.h"

@interface LEGoodStatusCell()
@property (weak, nonatomic) IBOutlet UIImageView *goodsIV;
@property (weak, nonatomic) IBOutlet UILabel *goodsNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *storageLabel;
@property (weak, nonatomic) IBOutlet UILabel *saleLabel;
//编辑
@property (weak, nonatomic) IBOutlet UIButton *firstButton;
//上架
@property (weak, nonatomic) IBOutlet UIButton *secondButton;
//删除
@property (weak, nonatomic) IBOutlet UIButton *thirdButton;
//推广
@property (weak, nonatomic) IBOutlet UIButton *fourthButton;
@property (weak, nonatomic) IBOutlet UIView *bottomView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomViewHeightCons;

/**
 <#Description#>
 */
@property(nonatomic,strong)goodsCellBlock block;

@end

@implementation LEGoodStatusCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (void)setModel:(LEOrderGoodsModel *)model
{
    _model = model;
    
    [self.goodsIV sd_setImageWithURL:[NSURL URLWithString:model.goods_image_url]];
    self.goodsNameLabel.text = model.goods_name;
    self.priceLabel.text = [NSString stringWithFormat:@"价格:%@",model.goods_price];
    self.storageLabel.text = [NSString stringWithFormat:@"库存:%@",model.sum];
    self.saleLabel.text = [NSString stringWithFormat:@"出售:%@",model.goods_salenum];
}
#pragma mark- 点击事件
- (void)goodsCellClick:(goodsCellBlock)block
{
    _block = block;
}
- (IBAction)firstClick:(UIButton *)sender {
    LELog(@"%s---%d---first",__func__,__LINE__);
    if (self.block) {
        _block(sender.tag,self.model);
    }
}
- (IBAction)secondClick:(UIButton *)sender {
    LELog(@"%s---%d---second",__func__,__LINE__);
    if (self.block) {
        _block(sender.tag,self.model);
    }
}
- (IBAction)thirdClick:(UIButton *)sender {
    LELog(@"%s---%d---thirdClick",__func__,__LINE__);
    if (self.block) {
        _block(sender.tag,self.model);
    }
    
}
- (IBAction)fourthClick:(UIButton *)sender {
    LELog(@"%s---%d---fourthClick",__func__,__LINE__);
    if (self.block) {
        _block(sender.tag,self.model);
    }
}
- (void)setStatus:(GoodStatus)status
{
    switch (status) {
        case On_Sale:
        {
            self.firstButton.hidden = YES;
            [_secondButton setTitle:@"下架" forState:0];
            self.thirdButton.hidden = YES;
        }
            break;
        case On_Storage:
        {
            self.bottomView.hidden = NO;
        }
            break;
        case Wait_Check:
        {
            self.bottomView.hidden = YES;
            self.bottomViewHeightCons.constant = 8;
        }
            break;
        case Sale_Out:
        {
            [self.firstButton setHidden:NO];
            [self.secondButton setHidden:YES];
            [self.thirdButton setHidden:YES];
            [self.fourthButton setHidden:YES];
        }
            break;
        case Check_Fail:
        {
            [self.firstButton setHidden:NO];
            [self.secondButton setHidden:YES];
            [self.thirdButton setHidden:NO];
            [self.fourthButton setHidden:YES];
            self.bottomViewHeightCons.constant = 45;
            
        }
            break;
            
        default:
            break;
    }
}

@end












